set more off
use "C:\Users\Andy baker\OneDrive - University of Colorado at Boulder Office 365\My Documents\Research\Paper PID Experiment\Mexico\Dataset OA NalMarch2016 - UColorado.dta", clear
local stick "C:\Users\Andy baker\OneDrive - University of Colorado at Boulder Office 365"
capture log close
log using "`stick'\My Documents\Research\Paper PID Experiment\Mexico\JOP Mexico Results.log", text replace
*version 14

*I. Experiment 1: Next 3 are different treatments of one experiment. Treatments indexed by Random1
	*1. working with sympathy(1) wording
gen sympathy1=C1T3
recode sympathy1 9=0 88=. 98=. 99=.

label values sympathy1 pid 

recode sympathy1 (0=1) (.=.) (else=0), gen(sympathy1_indep)
recode sympathy1 (1=1) (.=.) (else=0), gen(sympathy1_PAN)
recode sympathy1 (2=1) (.=.) (else=0), gen(sympathy1_PRI)
recode sympathy1 (3=1) (.=.) (else=0), gen(sympathy1_PRD)
recode sympathy1 (4=1) (.=.) (else=0), gen(sympathy1_MORENA)
recode sympathy1 (5=1) (.=.) (else=0), gen(sympathy1_PVEM)
recode sympathy1 (6=1) (.=.) (else=0), gen(sympathy1_Other)

ci proportions sympathy1*

	*2. working with sympathy(2) wording
		*NOTE THAT IN THE PAPER THIS WAS RENUMBERED TO 3!
gen sympathy2=C1T2
recode sympathy2 9=0 88=. 98=. 99=.

label values sympathy2 pid 

recode sympathy2 (0=1) (.=.) (else=0), gen(sympathy2_indep)
recode sympathy2 (1=1) (.=.) (else=0), gen(sympathy2_PAN)
recode sympathy2 (2=1) (.=.) (else=0), gen(sympathy2_PRI)
recode sympathy2 (3=1) (.=.) (else=0), gen(sympathy2_PRD)
recode sympathy2 (4=1) (.=.) (else=0), gen(sympathy2_MORENA)
recode sympathy2 (5=1) (.=.) (else=0), gen(sympathy2_PVEM)
recode sympathy2 (6=1) (.=.) (else=0), gen(sympathy2_Other)

ci proportions sympathy2*

	*3. working with sympathy(4) wording
gen sympathy4=C1T1b
replace sympathy4=0 if C1T1A==2
replace sympathy4=0 if C1T1b==9 | C1T1b==98  
replace sympathy4=. if C1T1A>3

label define pid 0 Independent 1 "PAN" 2 "PRI" 3 "PRD" 4 "MORENA" 5 "PVEM" 8 "Other"
label values sympathy4 pid 

recode sympathy4 (0=1) (.=.) (else=0), gen(sympathy4_indep)
recode sympathy4 (1=1) (.=.) (else=0), gen(sympathy4_PAN)
recode sympathy4 (2=1) (.=.) (else=0), gen(sympathy4_PRI)
recode sympathy4 (3=1) (.=.) (else=0), gen(sympathy4_PRD)
recode sympathy4 (4=1) (.=.) (else=0), gen(sympathy4_MORENA)
recode sympathy4 (5=1) (.=.) (else=0), gen(sympathy4_PVEM)
recode sympathy4 (6=1) (.=.) (else=0), gen(sympathy4_Other)

ci proportions sympathy4*

*II: Experiment 2: Next 3 are different treatments of one experiment. Treatments indexed by random3
	*1: working with close(1) wording
gen close1=C11T1
recode close1 9=0 88=. 98=. 99=.

label values close1 pid 

recode close1 (0=1) (.=.) (else=0), gen(close1_indep)
recode close1 (1=1) (.=.) (else=0), gen(close1_PAN)
recode close1 (2=1) (.=.) (else=0), gen(close1_PRI)
recode close1 (3=1) (.=.) (else=0), gen(close1_PRD)
recode close1 (4=1) (.=.) (else=0), gen(close1_MORENA)
recode close1 (5=1) (.=.) (else=0), gen(close1_PVEM)
recode close1 (6=1) (.=.) (else=0), gen(close1_Other)

ci proportions close1*

	*2: working with prefer(1) wording
gen prefer1=C11T2
recode prefer1 9=0 88=. 98=. 99=.

label values prefer1 pid 

recode prefer1 (0=1) (.=.) (else=0), gen(prefer1_indep)
recode prefer1 (1=1) (.=.) (else=0), gen(prefer1_PAN)
recode prefer1 (2=1) (.=.) (else=0), gen(prefer1_PRI)
recode prefer1 (3=1) (.=.) (else=0), gen(prefer1_PRD)
recode prefer1 (4=1) (.=.) (else=0), gen(prefer1_MORENA)
recode prefer1 (5=1) (.=.) (else=0), gen(prefer1_PVEM)
recode prefer1 (6=1) (.=.) (else=0), gen(prefer1_Other)

ci proportions prefer1*

	*3: working with identity(1) wording
gen identity1=C11T3
recode identity1 9=0 88=. 98=. 99=.

label values identity1 pid 

recode identity1 (0=1) (.=.) (else=0), gen(identity1_indep)
recode identity1 (1=1) (.=.) (else=0), gen(identity1_PAN)
recode identity1 (2=1) (.=.) (else=0), gen(identity1_PRI)
recode identity1 (3=1) (.=.) (else=0), gen(identity1_PRD)
recode identity1 (4=1) (.=.) (else=0), gen(identity1_MORENA)
recode identity1 (5=1) (.=.) (else=0), gen(identity1_PVEM)
recode identity1 (6=1) (.=.) (else=0), gen(identity1_Other)

ci proportions identity1*


*III. Randomization check
recode PA 2=1 1=0
recode Tipo 1=3 3=2 2=1
recode PB 98=.
recode i1 2=0
bysort Random1: ci mean PA PB Tipo i1

recode EA-EO (1=1) (2=0) (else=.)
polychoricpca EA EB EC ED EE EH EI EJ EK EM, score(wealthtemp) nscore(1)
impute wealthtemp EA EB EC ED EE EH EI EJ EK EM, gen(wealth)
recode PC 98=.
bysort random3: ci mean PA PB Tipo i1 PC wealth



*IV: Feeling thermometer variables
recode C8 88=. 98=. , gen(ft_PAN)
recode C9 88=. 98=. , gen(ft_PRI)
recode C10 88=. 98=. , gen(ft_PRD)

*V: Descriptives
summ identity1_PRI prefer1_PRI close1_PRI sympathy1_PRI sympathy2_PRI sympathy4_PRI identity1_PAN prefer1_PAN close1_PAN sympathy1_PAN sympathy2_PAN sympathy4_PAN identity1_PRD prefer1_PRD close1_PRD sympathy1_PRD sympathy2_PRD sympathy4_PRD

*VI: Statistical tests
egen indep_exp1=rsum(sympathy1_indep sympathy2_indep sympathy4_indep)
replace indep_exp1=. if sympathy1_indep==. & sympathy2_indep==. & sympathy4_indep==.
*this is test of sympathy1 to sympathy2
ttest indep_exp1 if Random1==3|Random1==2, by(Random1) unequal

*this is test of sympathy2 to sympathy4
ttest indep_exp1 if Random1==1|Random1==2, by(Random1) unequal

egen PRD_exp2=rsum(sympathy1_PRD sympathy2_PRD sympathy4_PRD)
replace PRD_exp2=. if sympathy1_PRD==. & sympathy2_PRD==. & sympathy4_PRD==.
*this is test of sympathy2 to sympathy4
ttest PRD_exp2 if Random1==1|Random1==2, by(Random1) unequal
drop PRD_exp2
egen indep_exp2=rsum(close1_indep prefer1_indep identity1_indep)
replace indep_exp2=. if close1_indep==. & prefer1_indep==. & identity1_indep==.
*this is test of prefer to consider
ttest indep_exp2 if random3==1|random3==3, by(random3) unequal
*this is test of closeness to consider
ttest indep_exp2 if random3==2|random3==3, by(random3) unequal

egen PRD_exp2=rsum(close1_PRD prefer1_PRD identity1_PRD)
replace PRD_exp2=. if close1_PRD==. & prefer1_PRD==. & identity1_PRD==.
*this is test of prefer to closeness
ttest PRD_exp2 if random3==1|random3==2, by(random3) unequal

egen PAN_exp2=rsum(close1_PAN prefer1_PAN identity1_PAN)
replace PAN_exp2=. if close1_PAN==. & prefer1_PAN==. & identity1_PAN==.
*this is test of prefer to consider
ttest PAN_exp2 if random3==1|random3==3, by(random3) unequal
*this is test of consider to closeness
ttest PAN_exp2 if random3==2|random3==3, by(random3) unequal

